{layout name="layout" /}
<div class="tipbox tipbox-warning">
    1、每次只能上传一个文件<br />
    2、上传前最好把文件名字修改为英文或数字。<br />
</div>
<div class="tipbox tipbox-message">
    <p><a href="javascript:;" id="upButton"><i class="iconfont icon-xuanze"></i> 点击选择上传的文件</a></p>
</div>
<script type="text/javascript">
Do('layer','upload',function(){
    var uploader = WebUploader.create({
        swf: '{__WEB__}js/Plug-in/uploader/Uploader.swf',
        server: '{:url('admin/base/upload')}',
        pick: {id: upButton,multiple: false},
        auto: true,
        accept: {innerHTML: '点击选择文件'}
    });
    //上传完毕
    uploader.on('uploadSuccess',function (file,data) {
        var index = parent.layer.getFrameIndex(window.name);
        var aValue = data.url;
        if(data.error == 1){
            layer.alert(data.message); 
        }else{
            parent.$("#iframe").contents().find("#{$input}").val(aValue)
            parent.$("#iframe").contents().find("#article").contents().find("#{$input}").val(aValue)
            parent.layer.close(index);
        }
    });
    uploader.on('uploadError', function (file) {
        layer.alert('文件上传失败'); 
    });
})
</script>